# import numpy as np  
# from scipy.interpolate import CubicSpline  
# import matplotlib.pyplot as plt  
  
# # 定义时间点和温度值  
# times = np.arange(1, 13)  # 1-12的整点时间  
# temperatures = np.array([5, 8, 9, 15, 25, 29, 31, 30, 22, 25, 27, 24])  
  
# # 创建三次样条插值对象  
# spline = CubicSpline(times, temperatures)  
  
# # 创建一个新的时间点数组，间隔为1/10小时  
# new_times = np.arange(1, 12 + 1/10, 1/10)  # 超出12一点点，以方便画图结果的呈现 
  
# # 使用样条插值对象估计这些时间点的温度值  
# new_temperatures = spline(new_times)  
  
# # 绘图  
# plt.plot(times, temperatures, 'o', label='Measured Temperatures')  
# plt.plot(new_times, new_temperatures, '-', label='Spline Interpolated Temperatures')  
# plt.xlabel('Time (hours)')  
# plt.ylabel('Temperature')  
# plt.title('Temperature vs Time')  
# plt.legend()  
# plt.grid(True)  
# plt.show()

import numpy as np  
from scipy.interpolate import CubicSpline  
import matplotlib.pyplot as plt  
  
# 定义插值数据点  
x = np.array([0, 3, 5, 7, 9, 11, 12, 13, 14, 15])  
y = np.array([0, 1.2, 1.7, 2.0, 2.1, 2.0, 1.8, 1.2, 1.0, 1.6])  
  
# 使用CubicSpline进行插值  
spline = CubicSpline(x, y)  
  
# 计算x坐标每改变0.1时的y坐标值  
new_x = np.arange(min(x), max(x) + 0.1, 0.1)  
new_y = spline(new_x)  
  
# 绘制插值曲线  
plt.plot(x, y, 'o', label='Original data points')  
plt.plot(new_x, new_y, label='Cubic Spline Interpolation')  
plt.xlabel('x')  
plt.ylabel('y')  
plt.title('Cubic Spline Interpolation Curve')  
plt.legend()  
plt.grid(True)  
plt.show()  
  
# 找出范围13 <= x <= 15下y的最小值  
x_range = new_x[(new_x >= 13) & (new_x <= 15)]  
y_min_in_range = np.min(spline(x_range))  
print(y_min_in_range)